﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="plan.aspx.cs" Inherits="EZCRS.HCMS.Web.manage.AIR.plan" %>

<%@ Register Src="../usercontrol/titlepage.ascx" TagName="titlepage" TagPrefix="uc2" %>
<%@ Register Assembly="Book38.Net.CustomControl" Namespace="Book38.Net.CustomControl"
    TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <link type="text/css" href="../../style/main.css" rel="Stylesheet" />
    
    <script src="../../common/calendar1.js" language="javascript" type="text/javascript"></script>
    <script src="../../Common/jquery-1.2.6.min.js"></script>
    
    <script>
    
        var sending = false;
        var hasColl = -1;
        
        $(document).ready(function() {
        
            $('form').submit(function(){
            
               if(hasColl == 1){
               
                    return confirm("部分计划与之前设置的时间段有冲突，是否继续？");
               }
               else if(hasColl == -1 && sending){
               
                    return confirm("正在验证计划时间段是否冲突，是否现在就提交？");

               }
               
               return true;
            });
        
            $("#btnsave").click(function() {
            
                //验证
                var regxDay = /^\d+$/;
                var regxNum = /^-?\d+$/;
                var regxRate = /^-?\d+(\.\d+)?$/;
                
                if(!checkValue('txtRate1', regxRate, true)) {
                    alert('请填写正确的单人价！');
                    return false;
                }
                
                if(!checkValue('txtRate2', regxRate, false)) {
                    alert('请填写正确的双人价！');
                    return false;
                }
                
                if(!checkValue('txtRate3', regxRate, false)) {
                    alert('请填写正确的三人价！');
                    return false;
                }
                
                if(!checkValue('txtRate4', regxRate, false)) {
                    alert('请填写正确的四人价！');
                    return false;
                }
                
                if(!checkValue('txtMin', regxDay, false)) {
                    alert('请填写正确的最小入住天数！');
                    return false;
                }
                
                if(!checkValue('txtMax', regxDay, false)) {
                    alert('请填写正确的最大入住天数！');
                    return false;
                }
                
                if(!checkValue('txtInventory', regxNum, true)) {
                    alert('请填写正确的房量！');
                    return false;
                }   
                 
                if(!checkValue('txtBFnum', regxNum, false)) {
                    alert('请填写正确的早餐数量！');
                    return false;
                }
                
                if(!checkValue('txtBFnum', regxRate, false)) {
                    alert('请填写正确的早餐价格！');
                    return false;
                }
                                                            
                return true;
                
            });
            
            
            $("#Radio1").click(function() {
                $('#startdate').attr('disabled', true);
                $('#enddate').attr('disabled', true);
                
                $('#Image1').attr('disabled', true);
                $('#Image2').attr('disabled', true); 
                
                $('#ddlSeasonList').attr('disabled', false);
                
                $('#cblWeek input').attr('disabled', true);
            });
            
            
            $("#Radio2").click(function() {
                $('#startdate').attr('disabled', false);
                $('#enddate').attr('disabled', false);
                
                $('#Image1').attr('disabled', false);
                $('#Image2').attr('disabled', false);
                
                $('#ddlSeasonList').attr('disabled', true);
                
                $('#cblWeek input').attr('disabled', false);
            });            
        
            $("#Radio2").click();
            
            $("#startdate").blur(function (){
            
                IsCollision();
            
            });
            
            $("#enddate").blur(function (){
            
                IsCollision();
            
            });
            
            $(".planlist input").click(function (){
            
                 IsCollision();
            });
            
            $("#ddlSeasonList").change(function (){
            
                IsCollision();
            });      
        });
        
        
        //检查是否存在冲突...
        function IsCollision(){
        
            if(sending) return;
            
            hasColl = -1;
            
            var strPlanCodeList = "";
            
            $(".planlist input").each(function(i){
                
                if($(this).attr("checked")){
                
                    var id = $(this).attr("id");
                    
                    var s = "#cblPlanList" + " label";

                    $(s).each(function(){
                        
                        if($(this).attr("for") == id) strPlanCodeList += $(this).text() + ",";
                        
                    });
                
                }
            
            });
            
            var seasonid = "";
            var startdate = "";
            var enddate = "";
            var sid = "";
            
            var bpass = false;
            
            if(strPlanCodeList != ""){
            
                //get date
                
                if($("#Radio2").attr("checked")){
                
                    //date range

                    startdate = $("#startdate").val();
                    enddate = $("#enddate").val();
                    
                    if(startdate != "yyyy-MM-dd" && enddate != "yyyy-MM-dd"){
                    
                        //pass
                        bpass = true;
                    }
                    
                }
                else{
                
                    //season id...

                    sid = $("select[@name='ddlSeasonList'] option[@selected]").val();
                    
                    if(sid != ""){
                        bpass = true;
                    }
                }
            }
            
            if(bpass && !sending){
                
                var data = {
                
                    startdate:startdate,
                    enddate:enddate,
                    season:sid,
                    codes:strPlanCodeList
                
                };
                
                $.post("?act=coll", data,
                
                    function(data, state){
                    
                         doCallback(data);
                                
                    }, "json");
               
               sending = true;
               $('#labcol').text("正在检查冲突...");
            }
            
        }
        
        function doCallback(r){
        
            if(r.coll != ""){
            
                $('#labcol').text("价格代码：" + r.coll + "与之前设置的时间段有冲突。");
                hasColl = 1;
            }
            else{
                $('#labcol').text("");
                
                hasColl = 0;
            }
            
            sending = false;
        
        }
        
        function checkValue(obj, regx, need) {

            var elem = document.getElementById(obj);
            
            if(elem.value == '' && need) {
                elem.focus();
                return false;
            }
            
            if(elem.value != ''){    
                if (!regx.exec(elem.value)) {
                    elem.focus();
                    return false;
                }
            }
            
            return true;
        }
        
    </script>
    
    <style>
        .planlist
        {
    	    margin-top:5px;
    	    overflow-x:hidden;
    	    overflow-y:auto;
        	
    	    width:200px;
    	    height:150px;
    	    border:solid 1px #D9ECFF;
        }
        
        #labcol
        {
        	color:Red;
        	font-weight:bold;
        }
        
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <uc2:titlepage ID="Titlepage1" runat="server" inittitle="<%$ Resources:Site, TitleExpression %>">
    </uc2:titlepage>
    <table cellpadding="0" cellspacing="0" class="main-table">
        <tr><td>
            <!--#include file="nav.htm"-->
            </td></tr>
            <tr class="line-even">
            <td>
                <table width="100%" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                        <td width="50%" valign="top">
                            <table align="center" border="0" cellspacing="0" cellpadding="0" class="maininfo">
                                <tr>
                                    <td colspan="2" class="minfo-title">
                                        计划级：
                                    </td>
                                </tr>
                                <tr>
                                    <td width="80">
                                        计划代码表：
                                    </td>
                                    <td>
                                        <div class="planlist">
                                        <asp:CheckBoxList ID="cblPlanList" runat="server">
                                        </asp:CheckBoxList>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="80">
                                        <input id="Radio1" type="radio" name="timespan" runat="server" />季节段：
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlSeasonList" runat="server">
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr>
                                    <td width="80">
                                        <input id="Radio2" type="radio" name="timespan" runat="server" />时间段：
                                    </td>
                                    <td>
                                        <input id="startdate" type="text" runat="server" class="text-line" 
                                            value="yyyy-MM-dd" />
                                        &nbsp;
                                        <input id="enddate" type="text" runat="server" class="text-line" 
                                            value="yyyy-MM-dd" />
                                            
                                            <label id="labcol"></label>
                                        </td>
                                </tr>
                                <tr>
                                    <td>
                                        星期设置：
                                    </td>
                                    <td>
                                        <asp:CheckBoxList ID="cblWeek" runat="server" RepeatDirection="Horizontal">
                                            
                                        </asp:CheckBoxList>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        可用性：
                                    </td>
                                    <td>
                                        <table width="100%">
                                            <tr>
                                                <td width=150>
                                                    状态：</td>
                                                <td>
                                                    <asp:DropDownList ID="ddlStatus" runat="server">
                                                        
                                                    </asp:DropDownList>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    最少入住天数：</td>
                                                <td>
                                                    <cc1:WebTextBox ID="txtMin" runat="server" CssClass="text-line" Width="50px"><Value>
</Value></cc1:WebTextBox></td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    最多入住天数：</td>
                                                <td>
                                                    <cc1:WebTextBox ID="txtMax" runat="server" CssClass="text-line" Width="50px"><Value>
</Value></cc1:WebTextBox></td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    提前预订期(小时) ：</td>
                                                <td>
                                                    <cc1:WebTextBox ID="txtAdv" runat="server" CssClass="text-line" Width="50px"><Value>
</Value></cc1:WebTextBox></td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    房量：</td>
                                                <td>
                                                    <cc1:WebTextBox ID="txtInventory" runat="server" CssClass="text-line" Width="50px"><Value>
</Value></cc1:WebTextBox></td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        保证金制度：
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlGuaRule" runat="server">
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        取消制度：
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlCxlRule" runat="server">
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        价格：
                                    </td>
                                    <td>
                                        单人价：<cc1:WebTextBox ID="txtRate1" runat="server" CssClass="text-line" Width="50px"><Value>
</Value></cc1:WebTextBox>双人价：<cc1:WebTextBox ID="txtRate2" runat="server" CssClass="text-line"
    Width="50px"><Value>
</Value></cc1:WebTextBox>三人价：<cc1:WebTextBox ID="txtRate3" runat="server" CssClass="text-line"
    Width="50px"><Value>
</Value></cc1:WebTextBox>四人价：<cc1:WebTextBox ID="txtRate4" runat="server" CssClass="text-line"
    Width="50px"><Value>
</Value></cc1:WebTextBox>加床：<cc1:WebTextBox ID="txtAddBed" runat="server" CssClass="text-line"
    Width="50px"><Value>
</Value></cc1:WebTextBox></td>
                                </tr>
                                <tr>
                                    <td>
                                        &nbsp;</td>
                                    <td>
                                        <asp:CheckBox ID="cbBreakfast" runat="server" Text="含早" />
&nbsp;早餐数量：<cc1:WebTextBox ID="txtBFnum" runat="server" CssClass="text-line"
    Width="50px"><Value>
</Value></cc1:WebTextBox>早餐价格：<cc1:WebTextBox ID="txtBFrate" runat="server" CssClass="text-line"
    Width="50px"><Value>
</Value></cc1:WebTextBox></td>
                                </tr>
                                </table>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" valign="middle">
                            <asp:Button ID="btnsave" runat="server" CssClass="bttn" Text="保存" 
                                onclick="btnsave_Click" />
                        </td>
                    </tr>
                </table>
            </td>
        </tr>
    </table>
    </form>
</body>
</html>

<script>


//initprovince();	
$F("navs3").className="title1";
</script>

